//
//  touchhellAppDelegate.m
//  touchhell
//
//  Created by omega on 08/12/21.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import "touchhellAppDelegate.h"
#import "EAGLView.h"
#import "hellApp.h"
#import "SoundEngine.h"

@implementation touchhellAppDelegate

@synthesize window;
@synthesize glView;

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    
	glView.animationInterval = HELL_FRAME_INTERVAL;
	[glView startAnimation];
	
	//application.idleTimerDisabled = YES;
	
	// SoundEngine Initalize
	NSLog( @"SoundEngine_Initialize:%d", SoundEngine_Initialize(44100));
	NSLog( @"SoundEngine_SetListenerPosition:%d" , SoundEngine_SetListenerPosition(0.0, 0.0, 1.0 /* listener distance */));
	
	// touchHell initalize
	Hell_initLoad();
	
	// acclerarometer
	[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(HELL_ACCELEROMETER_INTERVAL)];
	[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}


- (void)applicationWillResignActive:(UIApplication *)application {
	glView.animationInterval = 1.0 / 5.0;
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
	glView.animationInterval = HELL_FRAME_INTERVAL;
}

- (void)applicationWillTerminate:(UIApplication *)application {
	Hell_terminate();
}

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
	[glView updateAccelerometerWithX:acceleration.x Y:acceleration.y Z:acceleration.z];
}


- (void)dealloc {
	[window release];
	[glView release];
	[super dealloc];
}

@end
